package ch.roth.android.stationFinder.list;

import ch.roth.android.stationFinder.R;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class ListTheStations extends ListActivity {
	
    /** Called when the activity is first created. */	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	  super.onCreate(savedInstanceState);

	  String[] countries = getResources().getStringArray(R.array.countries);
	  setListAdapter(new ArrayAdapter<String>(this, R.layout.list_the_stations, countries));
	  
	  ListView lv = getListView();
	  lv.setTextFilterEnabled(true);
	  
	  OnItemClickListener listener = new OnItemClickListener() {
		public void onItemClick(AdapterView<?> parent, View view, int position,	long id) {
			Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
		}
	  };
	  lv.setOnItemClickListener(listener);
	}
	
}